#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=100005;
int n,m,l,v,T,p[N],s,tot1,tot2,ans;
struct st
{
    int d,v,a,jl,mas,qjl,hjl;
}a[N];
struct ct
{
    int xb,csc;
}b[N],c[N];
bool cmp(st x,st y)
{
    return x.d<y.d;
}
bool cmp1(ct x,ct y)
{
    return x.csc<y.csc;
}
bool cmp2(st x,st y)
{
    return x.hjl>y.hjl;
}
signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%lld",&T);
    for(int o=1;o<=T;o++)
    {
        tot1=tot2=s=ans=0;
        scanf("%lld%lld%lld%lld",&n,&m,&l,&v);
        for(int i=1;i<=n;i++)
            scanf("%lld%lld%lld",&a[i].d,&a[i].v,&a[i].a);
        for(int i=1;i<=m;i++)
            scanf("%lld",&p[i]);
        sort(p+1,p+1+m);
        sort(a+1,a+1+n,cmp);
        for(int i=1,j=1;i<=n;i++)
        {
            while(a[i].d>p[j]&&j<=m)j++;
            if(j<=m)a[i].jl=j;
        }
        for(int i=1;i<=n;i++)
            if(a[i].jl)
                if(a[i].a>0)
                    s+=(a[i].v*a[i].v+2*a[i].a*(p[m]-a[i].d)>v*v);
                else if(a[i].a==0)
                    s+=(a[i].v>v);
                else
                    s+=(a[i].v*a[i].v+2*a[i].a*(p[a[i].jl]-a[i].d)>v*v);

        for(int i=1;i<=n;i++)
            if(a[i].jl)
                if(a[i].a==0)
                {
                    if(a[i].v>v)
                        a[i].qjl=a[i].jl,a[i].hjl=m;
                }
                else if(a[i].a>0)
                {
                    if(a[i].v>v)
                    {
                        a[i].qjl=a[i].jl,a[i].hjl=m;
                        continue;
                    }
                    tot1++;
                    b[tot1].xb=i;
                    b[tot1].csc=a[i].d+floor(1.0*(v*v-a[i].v*a[i].v)/(2*a[i].a));
                }
                else
                {
                    if(a[i].v<=v||a[i].v*a[i].v+2*a[i].a*(p[a[i].jl]-a[i].d)<=v*v)continue;
                    tot2++;
                    c[tot2].xb=i;
                    c[tot2].csc=a[i].d+ceil(1.0*(v*v-a[i].v*a[i].v)/(2*a[i].a));
                }
        sort(b+1,b+1+tot1,cmp1);
        sort(c+1,c+1+tot2,cmp1);
        for(int i=1,j=1;i<=tot1;i++)
        {
            while(b[i].csc>p[j]&&j<=m)j++;
            if(j<=m)a[b[i].xb].qjl=j,a[b[i].xb].hjl=m;
        }
        for(int i=1,j=0;i<=tot2;i++)
        {
            while(c[i].csc>p[j+1]&&j<=m)j++;
            a[c[i].xb].qjl=a[c[i].xb].jl,a[c[i].xb].hjl=min(j,m);
        }
        sort(a+1,a+1+n,cmp2);
        int ma=INT_MAX;
        for(int i=1;i<=n;i++)
        {
            if(a[i].hjl==0)break;
            if(a[i].hjl<ma)
            {
                ma=a[i].qjl;
                ans++;
            }
            ma=max(ma,a[i].qjl);
        }
        printf("%lld %lld\n",s,m-ans);
        for(int i=1;i<=n;i++)
            a[i]=a[0],b[i]=b[0],c[i]=c[0],p[i]=0;
    }
    return 0;
}
